<?php

namespace app\admin\model;

use app\admin\model\BusPlatGroupConfig as PlatGroupModel;
use app\admin\model\Channel as ChannelModel;

//通道组
use think\Model;

/**
 * 渠道对接通道表模型
 * @package app\admin\model
 */
class BusChannelSendConfig extends Model
{
    public static function getAll($request = [])
    {
        $where['cor.cid'] = session('relate_id');
        if (!empty($request['country_code'])) {
            $where['cou.code'] = $request['country_code'];
        }
        $data = self::alias('cor')
            ->field('cou.country country_name,0+CAST(cor.price AS char) as price,cu.currency_code')
            ->join('bus_platfrom pla', 'pla.plat_id = cor.plat_id', 'LEFT')
            ->join('bus_country_code cou', 'cou.code = pla.country_code', 'LEFT')
            ->join('bus_supplier s', 's.supplier_code = pla.supplier_code', 'LEFT')
            ->join('bus_currency_type cu', 's.settlement_currency = cu.currency_code', 'LEFT')
            ->where($where)
            ->order('cor.id desc')
            ->paginate($request['limit'], false, ['query' => $request])
            ->toArray();
        return $data;
    }
}
